# -*- coding: utf-8 -*-
"""
Created on Mon Jan  8 21:24:35 2018

@author: admin
"""
from bs4 import BeautifulSoup
info = []
page = 0
while page < 20:
    page = page + 1
    with open('E:\ARCHer\python\安全教育平台\\question\\' + str(page) + '.html',encoding = 'utf-8') as wb_data:
        soup = BeautifulSoup( wb_data , 'lxml' )
        answers = soup.select('div.col-xs-9.split.pull-right > div > div.decidediv > table > tr:nth-of-type(2) > td:nth-of-type(2)')
        questions = soup.select( 'div > a' )
    for answer,question in zip( answers , questions ):
        data = {
                'answer':answer.get_text(),
                'question':question.get('href')
                }
        info.append(data)
for i in info:
    f = open('result.txt', 'a')
    f.write(i['question'] + '----' + i['answer'] + '\n')
    f.close()